# coding:utf-8

'''
    MGuide Framework
        
    Copyright (C) 2012  Alezy Oliveira Lima

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    @author: Alezy Oliveira Lima
    @contact: aol@ic.ufal.br
'''

class Item:
    
    id = None
    values = [] # values is a list of dicts like this: [ {'attr':'attribute', 'value':100, 'evaluation':None} ]
    finalEvaluation = None
    
    def __init__(self, values):
        self.values = values
        self.finalEvaluation = 0
        
    def __init__(self, id, values):
        self.id = id
        self.values = values
        self.finalEvaluation = 0
    
    def setId(self, id):
        self.id = id
    
    def setValues(self, values):
        self.values = values
        
    def setEvaluation(self, nameOfAttribute, evaluation):
        for i in self.values:
            if i.get('attr') == nameOfAttribute:
                i['evaluation']=evaluation
        
    def getId(self):
        return self.id
    
    def getValues(self):
        return self.values

    def getValue(self, nameOfAttribute):
        for i in self.values:
            if i.get('attr') == nameOfAttribute:
                return i.get('value')
         
    def getEvaluation(self, nameOfAttribute):
        for i in self.values:
            if i.get('attr') == nameOfAttribute:
                return i.get('evaluation')
    
    def getFinalEvaluation(self):
        self.finalEvaluation = 0
        for i in self.values:
            self.finalEvaluation += i.get('evaluation')
        return self.finalEvaluation